<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>登录页面</title>
    <link rel="stylesheet" href="css/login.css">
    <script src="js/jquery-3.6.0.js"></script>
    <link rel="stylesheet" href="font-awesome-4.7.0/css/font-awesome.css">
</head>
<script>
    $(function () {
        const LOGIN_URL = "http://localhost:8080/login/worker";
        $("#login").click(function () {
            let $workerId = $("#workerId").val();
            let $password = $("#password").val();
            let param = {
                workerId: $workerId,
                password: $password
            };
            if ($workerId === null || $workerId === "") {
                alert("员工ID不能为空")
            } else if ($password === null || $password === "") {
                alert("密码不能为空")
            } else {
                $.get(LOGIN_URL, param, function (result) {
                    if (result.status === 200) {
                        alert("登录成功")
                        window.location.href = "index.html";
                    } else if (result.status === 404) {
                        alert("账号或密码错误")
                    }
                })
            }
        })
    });
</script>

<body style="background: url('images/BG1.jpg') ;background-repeat:no-repeat ;background-size:100% 100% ;background-attachment: fixed ;">
<div id="login-box">
    <h1>登 录</h1>
    <div class="form">
        <div class="item">
            <i class="fa fa-user" aria-hidden="true"></i>
            <label for="workerId"></label>
            <input id="workerId" type="text" placeholder="请输入员工ID">
        </div>

        <div class="item">
            <i class="fa fa-key" aria-hidden="true"></i>
            <label for="password"></label>
            <input id="password" type="password" placeholder="请输入密码">
        </div>

        <div class="item" style="color: whitesmoke">
            还没有账号？<a href="register.html" class="txt2">立即注册</a>
        </div>
    </div>
    <button id="login">立 即 登 录</button>
</div>
</body>


</html>